import request from '@/utils/request'
/**
 * 获取收银订单列表
 * @param {*} params
 * @returns
 */
export function getOrdersList(params) {
  return request({
    url: '/api/app/orders/orders-list',
    method: 'get',
    baseURL: public_config.labor_api,
    params
  })
}

/**
 * 获取远程订单列表
 * @param {*} params
 * @returns
 */
export function getRemoteOrderList(params) {
  return request({
    url: '/api/app/orders/remote-orders-list',
    method: 'get',
    baseURL: public_config.labor_api,
    params
  })
}

/**
 * 按Id获取订单信息
 * @param {*} id
 * @returns
 */
export function getByIdOrderData(id) {
  return request({
    url: `/api/app/orders/${id}/orders`,
    method: 'get',
    baseURL: public_config.labor_api
  })
}

/**
 * 订单创建及修改
 * @param {*} data
 * @returns
 */
export function insertAndupdateOrder(data) {
  return request({
    url: '/api/app/orders/update-orders',
    method: 'post',
    baseURL: public_config.labor_api,
    cancelErrorReject: true,
    data
  })
}

/**
 * 新增远程订单
 * @param {*} data
 * @returns
 */
export function insertAndupdateRemoteOrder(data) {
  return request({
    url: '/api/app/orders/update-remote-orders',
    method: 'post',
    baseURL: public_config.labor_api,
    data
  })
}

/**
 *  取消订单
 * @param {*} id
 * @returns
 */
export function cancelByIdOrder(id) {
  return request({
    url: `/api/app/orders/orders-canceled/${id}`,
    method: 'post',
    baseURL: public_config.labor_api
  })
}

/**
 * 删除订单
 * @param {*} id
 * @returns
 */
export function deleteByIdOrder(id) {
  return request({
    url: `/api/app/orders/orders-delete/${id}`,
    method: 'post',
    baseURL: public_config.labor_api
  })
}
/**
 * 开始配送
 * @param {*} id
 * @returns
 */
export function dispatchByIdOrder(id) {
  return request({
    url: `/api/app/orders/orders-dispatch/${id}`,
    method: 'post',
    baseURL: public_config.labor_api
  })
}
/**
 * 撤销配送
 * @param {*} id
 * @returns
 */
export function revokeByIdOrder(id) {
  return request({
    url: `/api/app/orders/orders-revoke/${id}`,
    method: 'post',
    baseURL: public_config.labor_api
  })
}

/**
 * 结算订单
 * @param {*} data
 * @returns
 */
export function settleByIdOrder(data) {
  return request({
    url: 'api/app/orders/orders-settle',
    method: 'post',
    baseURL: public_config.labor_api,
    cancelErrorReject: true,
    data
  })
}

/**
 * 远程订单完成
 * @param {*} data
 * @returns
 */
export function finishSettleOrder(data) {
  return request({
    url: '/api/app/orders/orders-finish-settle',
    method: 'post',
    baseURL: public_config.labor_api,
    data
  })
}

/**
 * 获取下单商品列表
 * @param {*} param
 * @returns
 */
export function getQueryProductList(params) {
  return request({
    url: '/api/app/products/query-product-list',
    method: 'get',
    baseURL: public_config.labor_api,
    cancelErrorReject: true,
    params
  })
}

/**
 * 获取可退货的商品
 * @param {*} params
 * @returns
 */
export function getReturnProductList(params) {
  return request({
    url: '/api/app/orders/return-products-list',
    method: 'get',
    baseURL: public_config.labor_api,
    cancelErrorReject: true,
    params
  })
}

/**
 * 获取产品销售流水记录
 * @param {*} params
 * @returns
 */
export function getProductsLog(params) {
  return request({
    url: '/api/app/products-log',
    method: 'get',
    baseURL: public_config.labor_api,
    params
  })
}

/**
 * 获取员工信息
 * @param {*} params
 * @returns
 */
export function getEmployee(params) {
  return request({
    url: '/api/app/employee/employee',
    method: 'get',
    baseURL: public_config.labor_api,
    params
  })
}

export function getByCardEmployee(params) {
  return request({
    url: '/api/app/employee/employee-by-card',
    method: 'get',
    baseURL: public_config.labor_api,
    cancelErrorReject: true,
    params
  })
}
/**
 * 获取用户优惠券情况
 * @param {*} data
 * @returns
 */
export function getCouponByUser(data) {
  return request({
    url: '/api/app/coupon-used-relation/order-coupon-by-user',
    method: 'post',
    baseURL: public_config.labor_api,
    data
  })
}

export function getOrderCouponList(id) {
  return request({
    url: `/api/app/orders/order-coupon-list/${id}`,
    method: 'get',
    baseURL: public_config.labor_api
  })
}

/**
 * 获取一卡通接口
 * @param {*} params
 * @returns
 */
export function getCardData(data) {
  return request({
    url: '/labor-protection-invoker/api/Card/ReturnResult',
    method: 'post',
    baseURL: public_config.base_api,
    data
  })
}

export function getBalance(data) {
  return request({
    url: '/labor-protection-invoker/api/CardNiu/GetBalance',
    method: 'post',
    baseURL: public_config.base_api,
    data
  })
}

// 根据当前登录人获取名称
export function getUserName(params) {
  return request({
    url: '/api/app/employee/employee-by-name',
    method: 'get',
    baseURL: public_config.labor_api,
    params
  })
}

// 导出远程模板
export function exportRemoteOrderDemo(params) {
  return request({
    url: '/api/Export/GetRemoteOrdersProdListExcel',
    method: 'get',
    baseURL: public_config.labor_api,
    responseType: 'blob',
    params
  })
}

// 远程下单导入Excel
export function importMaterial(data) {
  return request({
    url: '/api/app/coupon-used-relation/import-remote-order',
    method: 'post',
    baseURL: public_config.labor_api,
    data
  })
}
